"ddd"
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
import pyautogui
import win32gui
import win32con
"""
带有input标签并且type属性的值为file可直接使用send_keys方法上传文件


"""
# #上传input
# driver = webdriver.Chrome()
#
# driver.get(r"D:\daima\xin-daima\kejian\webUI自动化测试\HTML\load_dang.html")
# time.sleep(3)
# upload = driver.find_element_by_name('file')
# upload.send_keys(r"D:\daima\xin-daima\kejian\webUI自动化测试\4，selenium的操作总结\test7_多窗口的切换.py")

#上传非input标签
driver = webdriver.Chrome()
driver.get(r"http://sahitest.com/demo/php/fileUpload.htm")
driver.maximize_window()
driver.implicitly_wait(10)
time.sleep(3)
# driver.find_element_by_name('file').click()
pyautogui.moveTo(68,190,2)
pyautogui.leftClick()

#找元素，一级窗口“#32770”，打开
time.sleep(1)
dialog = win32gui.FindWindow("#32770","打开") #对话框
#向下传递
time.sleep(1)
ComboBoxEx32 = win32gui.FindWindowEx(dialog,0,'ComboBoxEx32',None) #二级
time.sleep(1)
ComboBox = win32gui.FindWindowEx(ComboBoxEx32,0,'ComboBox',None) #三级
time.sleep(1)
#编辑按钮
Edit = win32gui.FindWindowEx(ComboBox,0,'Edit',None) #上面三句依次寻找对象，直到找到输入Edit对象的句柄
time.sleep(1)
#打开按钮
button = win32gui.FindWindowEx(dialog,0,'Button',None) #确定按钮Button
time.sleep(1)
#输入文件的绝对路径，点击打开按钮
win32gui.SendMessage(Edit,win32con.WM_SETTEXT,None,
                     r"D:\daima\xin-daima\kejian\webUI自动化测试\4，selenium的操作总结\test1_鼠标事件.py")
time.sleep(1)
win32gui.SendMessage(dialog,win32con.WM_COMMAND,1,button) #点击打开按钮
time.sleep(1)










